#ifndef SCENEEDITORDISPLAY_H
#define SCENEEDITORDISPLAY_H

#include "moveit/rviz_plugin_scene_editor/scene_editor_display_helper.h"

#include <rviz/display.h>
#include <rviz/panel_dock_widget.h>
#include <moveit/rviz_plugin_render_tools_mirror/trajectory_visualization.h>

#ifndef Q_MOC_RUN
#include <moveit/robot_interaction/robot_interaction.h>
#include <moveit/robot_interaction/interaction_handler.h>

#include <moveit/planning_scene_monitor/planning_scene_monitor.h>
#include <moveit/kinematics_metrics/kinematics_metrics.h>
#include <moveit/dynamics_solver/dynamics_solver.h>

#include <ros/ros.h>

#include <std_msgs/String.h>
#include <moveit_msgs/DisplayTrajectory.h>
#endif

#include <memory>

namespace moveit_rviz_plugin_scene_editor
{
class SceneEditorFrame;

class SceneEditorDisplay : public SceneEditorDisplayHelper
{
  Q_OBJECT

public:
  SceneEditorDisplay();
  ~SceneEditorDisplay() override;

  void load(const rviz::Config& config) override;
  void save(rviz::Config config) const override;
  void update(float wall_dt, float ros_dt) override;
  void reset() override;

protected:
  // overrides from Display
  void onInitialize() override;
  void onEnable() override;
  void onDisable() override;
  void fixedFrameChanged() override;

  // new virtual functions added by this plugin
  void updateInternal(float wall_dt, float ros_dt) override;
  void onSceneMonitorReceivedUpdate(planning_scene_monitor::PlanningSceneMonitor::SceneUpdateType update_type) override;

  void onRobotModelLoaded() override;

private Q_SLOTS:
  void motionPanelVisibilityChange(bool enable);

private:
  void backgroundJobUpdate(moveit::tools::BackgroundProcessing::JobEvent /*unused*/, const std::string& /*unused*/);
  void updateBackgroundJobProgressBar();

  // Pick Place
  void clearPlaceLocationsDisplay();
  void visualizePlaceLocations(const std::vector<geometry_msgs::PoseStamped>& place_poses);
  std::vector<std::shared_ptr<rviz::Shape> > place_locations_display_;

  SceneEditorFrame* frame_;
  rviz::PanelDockWidget* frame_dock_;
};
}  // namespace moveit_rviz_plugin_scene_editor

#endif  // SCENEEDITORPANEL_H
